/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */

package cn.webrx;

import java.util.OptionalInt;
import java.util.stream.IntStream;

/**
 * <p>Project: jse2303 - Stream3</p>
 * <p>Powered by webrx On 2023-07-25 15:39:08</p>
 * <p>描述：<p>
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Stream5 {
    public static void main(String[] args) {
        IntStream is = IntStream.of(11, 1, 2, 3, 4, 5, 6, 7, 22, 9, 1, 222, 9, 8, 1, 2, 4, 9).parallel();

        //判断流数据集中所有元素都必须>=5
        //boolean b = is.allMatch(e -> e >= 5);

        //判断流有元素匹配
        //boolean b = is.anyMatch(e -> e >= 5);

        //boolean b = is.noneMatch(e -> e >= 50);
        //OptionalInt first = is.findFirst();
        //System.out.println(first.getAsInt());

        //
        //Optional<Integer> op = Optional.empty();
        OptionalInt any = is.parallel().findAny();
        if (any.isPresent()) {
            System.out.println(any.getAsInt());
        }

    }
}
